package org.example3;

import org.example2.CustomerInvocationHandler;
import org.example2.CustomerProxyFactory;
import org.example2.ZhangSan;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 *  调用手写源码 $Proxy
 */
public class App$ProxyMain {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException,
            IllegalAccessException, InvocationTargetException, InstantiationException {

        String clazz = "org.example3.$Proxy";

        Class<?> aClass = Class.forName(clazz);

        Constructor<?> declaredConstructor = aClass.getDeclaredConstructor(CustomerInvocationHandler.class);

        $Proxy o =($Proxy) declaredConstructor.newInstance(new CustomerProxyFactory(new ZhangSan()));

        o.findLove();

    }
}
